//
//  CommunityWeb.m
//  Qyer
//
//  Created by dllo on 15/10/21.
//  Copyright (c) 2015年 GF. All rights reserved.
//

#import "CommunityWeb.h"

@interface CommunityWeb ()<UIWebViewDelegate>
@property (nonatomic, strong)UIWebView *web;
@property (nonatomic, strong)UIView *navBar;
//@property (nonatomic, strong)UIButton *backButton;
@end

@implementation CommunityWeb
- (void)viewWillAppear:(BOOL)animated {
}
- (void)viewWillDisappear:(BOOL)animated {
    [GiFHUD dismiss];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.automaticallyAdjustsScrollViewInsets = NO;
    self.navigationController.navigationBar.hidden = YES;
    [self creatCustomNavigationBar];
    _web = [[UIWebView alloc] initWithFrame:CRM(0, 64, SCREEN_WIDTH, SCREEN_HEIGHT - 64)];
    _web.scalesPageToFit = YES;
    _web.delegate = self;
    _web.scrollView.bounces = NO;
    [self.view addSubview:_web];
    
    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:self.urlStr]];
    [_web loadRequest:request];
    [GiFHUD setGifWithImageName:@"9707070_11.gif"];
}
#pragma mark - custom navigationBar
- (void)creatCustomNavigationBar {
    _navBar = [[UIView alloc] initWithFrame:CRM(0, 0, SCREEN_WIDTH, 64)];
    _navBar.layer.borderColor = [UIColor lightGrayColor].CGColor;
    _navBar.layer.borderWidth = 0.5;
    _navBar.backgroundColor = DAY_BACKGROUND;
    [self.view addSubview:_navBar];
    UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
    backButton.frame = CGRectMake(20, 30, 25, 20);
    [backButton setImage:[UIImage imageNamed:@"iconfont-fanhui"] forState:UIControlStateNormal];
    [backButton addTarget:self action:@selector(backClick) forControlEvents:UIControlEventTouchUpInside];
    [_navBar addSubview:backButton];
}
- (void)backClick {
    self.navigationController.navigationBar.hidden = NO;
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)webViewDidStartLoad:(UIWebView *)webView {
    [GiFHUD show];
}
- (void)webViewDidFinishLoad:(UIWebView *)webView {
    [GiFHUD dismiss];
}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
    [GiFHUD dismiss];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
